<!DOCTYPE html>
<html>
<head>
    <title>意见建议</title>
    <meta charset="UTF-8">
    <style>
        body { 
            font-family: Arial, sans-serif;
            background: #f5f5f5;
            margin: 0;
            padding: 20px;
        }
        .container {
            max-width: 800px;
            margin: 0 auto;
            background: white;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        h1 {
            text-align: center;
            color: #333;
            margin-bottom: 20px;
        }
        .desc {
            color: #666;
            margin-bottom: 30px;
            text-align: center;
        }
        .form-group {
            margin-bottom: 20px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            color: #333;
        }
        input[type="text"] {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        textarea {
            width: 100%;
            height: 150px;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            resize: vertical;
            box-sizing: border-box;
        }
        .submit-btn {
            background: #8b0000;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 4px;
            cursor: pointer;
            width: 100%;
            font-size: 16px;
        }
        .submit-btn:hover {
            background: #a00000;
        }
        .success-tip {
            background: #e8f5e9;
            color: #2e7d32;
            padding: 10px;
            border-radius: 4px;
            margin-top: 10px;
            text-align: center;
            display: none;
        }
        .admin-info {
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid #eee;
            color: #666;
            font-size: 14px;
            text-align: right;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>意见建议</h1>
        <div class="desc">请提供宝贵意见建议或其他史料内容，让我们共同建好用好军史场馆。</div>
        
        <div class="form-group">
            <label>姓名</label>
            <input type="text" id="name" placeholder="请输入您的姓名">
        </div>
        
        <div class="form-group">
            <label>电话</label>
            <input type="text" id="phone" placeholder="请输入您的联系电话">
        </div>
        
        <div class="form-group">
            <label>内容</label>
            <textarea id="content" placeholder="请输入意见建议内容..."></textarea>
        </div>
        
        <button onclick="submitFeedback()" class="submit-btn">提 交</button>
        <div id="successTip" class="success-tip">提交成功，感谢您的建议！</div>

    </div>

    <script>
        async function submitFeedback() {
            const name = document.getElementById('name').value.trim();
            const phone = document.getElementById('phone').value.trim();
            const content = document.getElementById('content').value.trim();
            
            if (!name || !phone || !content) {
                alert('请填写完整信息');
                return;
            }

            try {
                const response = await fetch('save_feedback.php', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json'
                    },
                    body: JSON.stringify({
                        name: name,
                        phone: phone,
                        content: content,
                        created_at: new Date().toISOString(),
                        status: 'pending'
                    })
                });

                if (!response.ok) throw new Error('提交失败');

                // 清空表单
                document.getElementById('name').value = '';
                document.getElementById('phone').value = '';
                document.getElementById('content').value = '';
                
                // 显示成功提示
                const successTip = document.getElementById('successTip');
                successTip.style.display = 'block';
                setTimeout(() => {
                    successTip.style.display = 'none';
                }, 3000);
                
            } catch (error) {
                console.error('提交失败:', error);
                alert('提交失败，请重试');
            }
        }
    </script>
</body>
</html> 